<?php
    
    require_once('../SiteIncludes.GLOBAL.php');
    
    if(EclipseMDE::runningOnMod_Rewrite() === false) {
	// Security Guard, Do Not Let This be accessed by any other means than mod_rewrite
	$gVAR['e'] = '404';
	require_once('error_handler.php');
	die();
    }
    
    
    /**
     * We are on an editing page, so we will add the timeout warning js 
     */
    $TemplateEngine->add_postloadScript('<script type="text/javascript" src="/js/inactivityWarning.js"></script>');
    $TemplateEngine->add_postloadScript('<script type="text/javascript">inactivity_hour();</script>');
    
    // Add Javascript for cleanup script and confirmer script
    $TemplateEngine->add_postloadScript('<script type="text/javascript" src="/js/ajaxCleanup.js"></script>');
    $TemplateEngine->add_postloadScript('<script type="text/javascript" src="/js/ajaxConfirmer.js"></script>');
    // Ensure all variables needed are set
    if(isset($_LOGGEDINUSER) === true && $_LOGGEDINUSER !== false && isset($gVAR['alias']) !== false) {
	try {
	    $Project =& $ProjectStash->get($gVAR['alias']);
	    // Tool Name in the JS
	    $TemplateEngine->add_preloadScript('<script type="text/javascript">var tool_name=\''.$Project->getAlias().'\';</script>');
	    
		/**
		 * Administration Privi Required:
		 *	Either a website admin OR
		 *	Lead Maintainer 
		 */
	    if($Project->userCanAdmin($_LOGGEDINUSER->get_userid()) === true) {
		
	    } else {
		$gVAR['e'] = 403;
		require_once('error_handler.php');
		die();
	    }
	} catch(InvalidProjectException $e) {
	    $gVAR['e'] = 404;
	    require_once('error_handler.php');
	    die();
	}
    } else {
	$gVAR['e'] = 403;
	require_once('error_handler.php');
	die();
    }
    
    
?>